package com.niji.littly_donkey_android.adapter;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.makeramen.roundedimageview.RoundedImageView;
import com.niji.littly_donkey_android.R;
import com.niji.littly_donkey_android.bean.Comment;
import com.niji.littly_donkey_android.bean.CommissionRank;
import com.niji.littly_donkey_android.util.NetworkGlideImageLoader;
import com.niji.littly_donkey_android.view.StarRatingView;

import java.util.ArrayList;

public class CommissionRankAdapter extends ArrayAdapter<CommissionRank> {


    private static final String TAG = "CommissionRankAdapter";

    private Context context;

    public CommissionRankAdapter(Context context, ArrayList<CommissionRank> members)
    {
        super(context,0, members);
        this.context = context;
    }
    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        CommissionRank commissionRank = getItem(position);

        if(convertView == null)
        {
            convertView = LayoutInflater.from(getContext()).inflate(R.layout.item_commission_rank, parent, false);
        }

        TextView commissionTitle = convertView.findViewById(R.id.commission_rank_title);
        TextView commissionName = convertView.findViewById(R.id.commission_rank_name);
        TextView commissionNumber = convertView.findViewById(R.id.commission_rank_number);
        ImageView commissionImg = convertView.findViewById(R.id.commission_rank_img);
        //thumb.setImageBitmap(BitMap.getInstance().returnBitMap(u.getThumb()));
        commissionTitle.setText(commissionRank.getTitle());
        commissionName.setText(commissionRank.getName());
        commissionNumber.setText(commissionRank.getNumber());
        NetworkGlideImageLoader.getInstance().displayImage((Activity) context, commissionRank.getImg(), commissionImg,0,0);
        if ("1.".equals(commissionNumber.getText().toString().trim()) || "2.".equals(commissionNumber.getText().toString().trim()) || "3.".equals(commissionNumber.getText().toString().trim())){
            commissionNumber.setTextColor(Color.parseColor("#ffba00"));
        }else {
            commissionNumber.setTextColor(Color.parseColor("#666666"));
        }
        return convertView;
    }

}



